package com.xd.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


/**
 * Created with IDEA
 *
 * @author xp
 * @date 2019/2/19 15:34
 */
@Configuration
@EnableSwagger2
public class SwaggerConfiguration {
   /* @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.example.demo.Controller"))
                .paths(PathSelectors.regex("/rest/.*"))
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("TongLing系统Restful API")
                .description("TongLing系统Restful API")
                .termsOfServiceUrl("http://127.0.0.1:8080/")
                .contact("xp")
                .version("1.0")
                .build();
    }*/

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.dzqc.exam.controller"))
               /* .paths(PathSelectors.any())*/
                .paths(PathSelectors.regex("/.*"))
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("单招系统接口文档")
                .description("单招系统——学生端")
                .termsOfServiceUrl("http://localhost:8080/")
                .contact("白居易")
                .version("1.0")
                .build();
    }

}